package Main;

import Utils.JdbcUtils;
import Utils.MD5Utils;
/*
* 测试类
* */
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class jdbc {
    public static void main(String[] args) {
        Connection connection = JdbcUtils.getConnection();
        PreparedStatement statement = null;
        ResultSet resultSet = null;
        String sql = "select * from t_user where username = ? and password = ?";
        String admin = MD5Utils.encrypt("admin");
        try {
            statement = connection.prepareStatement(sql);
            statement.setString(1, "admin");
            statement.setString(2, admin);
            resultSet = statement.executeQuery();
            while (resultSet.next()){
                int id = resultSet.getInt("id");
                String username1 = resultSet.getString("username");
                String password1 = resultSet.getString("password");
                String nickname = resultSet.getString("nickname");
                System.out.println(id+"_"+username1+"_"+password1+"_"+nickname);

            }

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JdbcUtils.close(connection, statement,resultSet);
        }

    }
}
